import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import NoteDetail from "@/views/note/NoteDetail.vue";

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: HomeView,
      redirect: ()=>{return '/note'},
      meta: { keepAlive: true }, // 缓存
      children:[
          {
            path: '/note',
            name: 'note',
            component: () => import('../views/note/note.vue'),
            meta: { keepAlive: true }  // 缓存
          },
          {
            path: '/note/:id',
            name: 'noteDetail',
            component: NoteDetail,
            props: true,
            meta: { keepAlive: false }  // 不缓存
          },
          {
            path: '/history',
            name: 'history',
            component: () => import('../views/note/history.vue'),
            meta: { keepAlive: true }  // 缓存
          },
          {
            path: '/blog',
            name: 'blog',
            component: () => import('../views/blog.vue'),
               meta: { keepAlive: true }  // 缓存
          },
          {
            path: '/category',
            name: 'category',
            component: () => import('../views/note/CategoryView.vue'),
               meta: { keepAlive: true }  // 缓存

          },
      ]
    },
  ]
})

export default router
